package model.playable.structure;
import java.util.*;
import model.command.*;
import model.playable.unit.Worker;
/**
 *
 * @author Ryan
 */
public abstract class MannedStructure extends Structure implements OrderWorkerable
{
	private int workerUpkeep;
	private int workerRadius;
	private int workerDensity;
	private ArrayList<Worker>workers;
	private int productionRate;
	
	public int getWorkerUpkeep()
	{
		return workerUpkeep;
	}
	
	public void setWorkerUpkeep(int workerUpkeep)
	{
		this.workerUpkeep = workerUpkeep;
	}
	
	public int getWorkerRadius()
	{
		return workerRadius;
	}
	
	public void setWorkerRadius(int workerRadius)
	{
		this.workerRadius = workerRadius;
	}
	
	public int getWorkerDensity()
	{
		return workerDensity;
	}
	
	public void setWorkerDensity(int workerDensity)
	{
		this.workerDensity = workerDensity;
	}
	
	public ArrayList<Worker> getWorkers()
	{
		return workers;
	}
	
	public void setWorkers(ArrayList<Worker> workers)
	{
		this.workers = workers;
	}
	
	public int getProductionRate()
	{
		return productionRate;
	}
	
	public void setProductionRate(int productionRate)
	{
		this.productionRate = productionRate;
	}
	
	public Worker removeWorker()
	{
		//todo
		return null;
	}
	
	public void addWorkerUpkeep(int amount)
	{
		if(getWorkerUpkeep() <= amount)
		{
			incrementHealth(-2);
		}
	}
	
	public void addWorkers(Worker[] workers)
	{
		for(int i = 0; i < workers.length; i++)
		{
			this.workers.add(workers[i]);
		}
	}
	
	public void incrementProductionRate(int increment)
	{
		productionRate += increment;
	}
	
	public void incrementWorkerDensity(int increment)
	{
		workerDensity += increment;
	}
	
	public void incrementWorkerRadius(int increment)
	{
		workerRadius += increment;
	}
	
	public void unassignAllWorkers()
	{
		for(int i = 0; i < workers.size(); i++)
		{
			workers.get(i).setCommandQueue(new LinkedList<Command>());
			workers.get(i).setAvailable(true);
		}
	}
	
	public void assignWorkers(int amount, Command command)
	{
		int count = 0;
		for(int i = 0; i < workers.size(); i++)
		{
			if(count==amount)
				break;
			else
			{
				if(workers.get(i).getAvailable())
				{
					workers.get(i).addToCommandQueue(command);
					count++;
				}
			}
		}
	}
	
}



